package com.algo.moduleSeven;

public class JumpTwo {
    public int jump(int[] nums) {
        int n = nums.length;
        int[] dp = new int[n];
        // dp[i] = Math.min(dp[i], dp[j]+1);
        dp[0] = 0;
        for(int i = 1; i < n; i++){
            dp[i] = 100000000;
            for(int j = 0; j <= i; j++){
                if(i <= j + nums[j]){
                    dp[i] = Math.min(dp[i], dp[j]+1);
                }

            }
        }


        return dp[nums.length -1];
    }
}
